Stack CreateStack( int MaxSize )
{
	Stack S=(Stack)malloc(sizeof(struct SNode));
	S->Data=(ElementType *)malloc(MaxSize*sizeof(ElementType));
	S->Top1=-1;
	S->Top2=MaxSize;
	S->MaxSize=MaxSize;
	return S;
}
bool Push( Stack S, ElementType X, int Tag ){
	if(S->Top1+1==S->Top2){
		printf("Stack Full\n");
		return false;
	}	
	else if(Tag==1){
		if(S->Top1==S->MaxSize-1){
			printf("Stack Full\n");
			return false;
		}
		S->Top1++;
		S->Data[S->Top1]=X;
	}
	else if(Tag==2){
		if(S->Top2==0){
			printf("Stack Full\n");
			return false;
		} 
		S->Top2--;
		S->Data[S->Top2]=X;
	return true;
}
}
ElementType Pop( Stack S, int Tag ){
	int a;
	if(Tag==1){
		if(S->Top1==-1) {
		printf("Stack 1 Empty\n");
		return ERROR;
	}
	a=S->Data[S->Top1];
	S->Top1--;
	}
	else if(Tag==2){
		if(S->Top2==S->MaxSize) {
		printf("Stack 2 Empty\n");
		return ERROR;
	}
	a=S->Data[S->Top2];
	S->Top2++;
	}
	return a;
}
